﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Weight.Base.Utility
{
   public   class DataTableHelper
    {
        /// <summary>
        /// 获取数据DataTable 第一个字符串列的索引
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static  int GetDtFirstStringIndex(DataTable dt)
        {
            if (dt == null) return -1;
            int index = 0;
            foreach (DataColumn item in dt.Columns)
            {
                if (item.ColumnName == "Id")
                {
                    index++;
                    continue;
                }
                if (item.DataType.Name == "String")
                {
                    return index;
                }
                index++;
            }
            return index;
        }
    }
}
